﻿using System;
using System.Collections.ObjectModel;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace G.SL.Controls
{
    public static class PageMenuService
    {
        public static readonly DependencyProperty MenuProperty = DependencyProperty.RegisterAttached("Menu", typeof(ObservableCollection<MenuItem>), typeof(PageMenuService), null);

        public static ObservableCollection<MenuItem> GetMenu(Page element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            ObservableCollection<MenuItem> items = element.GetValue(MenuProperty) as ObservableCollection<MenuItem>;
            if (items == null)
            {
                items = new ObservableCollection<MenuItem>();
                SetMenu(element, items);
            }
            return items;
        }

        public static void SetMenu(Page element, ObservableCollection<MenuItem> value)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            element.SetValue(MenuProperty, value);
        }
    }
    public class MenuItem
    {
        public MenuItem()
        {
            this.Items = new ObservableCollection<MenuItem>();
        }
        public string Name { get; set; }

        public ObservableCollection<MenuItem> Items { get; set; }

        public G.SL.MVVM.CallBackCommand Command { get; set; }

        public object CommandParamter { get; set; }
        /// <summary>
        /// 是否有分割线
        /// </summary>
        public bool HasSplitter { get; set; }
    }
}
